.class public Lorg/jboss/netty/channel/ChannelLocal;
.super Ljava/lang/Object;
.source "ChannelLocal.java"


# annotations
.annotation system Ldalvik/annotation/Signature;
    value = {
        "<T:",
        "Ljava/lang/Object;",
        ">",
        "Ljava/lang/Object;"
    }
.end annotation


# instance fields
.field private final map:Ljava/util/concurrent/ConcurrentMap;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/concurrent/ConcurrentMap",
            "<",
            "Lorg/jboss/netty/channel/Channel;",
            "TT;>;"
        }
    .end annotation
.end field

.field private final removeOnClose:Z

.field private final remover:Lorg/jboss/netty/channel/ChannelFutureListener;


# direct methods
.method public constructor <init>()V
    .locals 1

    .prologue
    .line 51
    .local p0, this:Lorg/jboss/netty/channel/ChannelLocal;,"Lorg/jboss/netty/channel/ChannelLocal<TT;>;"
    const/4 v0, 0x0

    invoke-direct {p0, v0}, Lorg/jboss/netty/channel/ChannelLocal;-><init>(Z)V

    .line 52
    return-void
.end method

.method public constructor <init>(Z)V
    .locals 1
    .parameter "removeOnClose"

    .prologue
    .line 59
    .local p0, this:Lorg/jboss/netty/channel/ChannelLocal;,"Lorg/jboss/netty/channel/ChannelLocal<TT;>;"
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 35
    new-instance v0, Lorg/jboss/netty/util/internal/ConcurrentIdentityWeakKeyHashMap;

    invoke-direct {v0}, Lorg/jboss/netty/util/internal/ConcurrentIdentityWeakKeyHashMap;-><init>()V

    iput-object v0, p0, Lorg/jboss/netty/channel/ChannelLocal;->map:Ljava/util/concurrent/ConcurrentMap;

    .line 39
    new-instance v0, Lorg/jboss/netty/channel/ChannelLocal$1;

    invoke-direct {v0, p0}, Lorg/jboss/netty/channel/ChannelLocal$1;-><init>(Lorg/jboss/netty/channel/ChannelLocal;)V

    iput-object v0, p0, Lorg/jboss/netty/channel/ChannelLocal;->remover:Lorg/jboss/netty/channel/ChannelFutureListener;

    .line 60
    iput-boolean p1, p0, Lorg/jboss/netty/channel/ChannelLocal;->removeOnClose:Z

    .line 61
    return-void
.end method


# virtual methods
.method public get(Lorg/jboss/netty/channel/Channel;)Ljava/lang/Object;
    .locals 4
    .parameter "channel"
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Lorg/jboss/netty/channel/Channel;",
            ")TT;"
        }
    .end annotation

    .prologue
    .line 74
    .local p0, this:Lorg/jboss/netty/channel/ChannelLocal;,"Lorg/jboss/netty/channel/ChannelLocal<TT;>;"
    if-nez p1, :cond_0

    .line 75
    new-instance v2, Ljava/lang/NullPointerException;

    const-string v3, "channel"

    invoke-direct {v2, v3}, Ljava/lang/NullPointerException;-><init>(Ljava/lang/String;)V

    throw v2

    .line 78
    :cond_0
    iget-object v2, p0, Lorg/jboss/netty/channel/ChannelLocal;->map:Ljava/util/concurrent/ConcurrentMap;

    invoke-interface {v2, p1}, Ljava/util/concurrent/ConcurrentMap;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v1

    .line 79
    .local v1, value:Ljava/lang/Object;,"TT;"
    if-nez v1, :cond_1

    .line 80
    invoke-virtual {p0, p1}, Lorg/jboss/netty/channel/ChannelLocal;->initialValue(Lorg/jboss/netty/channel/Channel;)Ljava/lang/Object;

    move-result-object v1

    .line 81
    if-eqz v1, :cond_1

    .line 82
    invoke-virtual {p0, p1, v1}, Lorg/jboss/netty/channel/ChannelLocal;->setIfAbsent(Lorg/jboss/netty/channel/Channel;Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v0

    .line 83
    .local v0, oldValue:Ljava/lang/Object;,"TT;"
    if-eqz v0, :cond_1

    .line 84
    move-object v1, v0

    .line 88
    .end local v0           #oldValue:Ljava/lang/Object;,"TT;"
    :cond_1
    return-object v1
.end method

.method protected initialValue(Lorg/jboss/netty/channel/Channel;)Ljava/lang/Object;
    .locals 1
    .parameter "channel"
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Lorg/jboss/netty/channel/Channel;",
            ")TT;"
        }
    .end annotation

    .prologue
    .line 67
    .local p0, this:Lorg/jboss/netty/channel/ChannelLocal;,"Lorg/jboss/netty/channel/ChannelLocal<TT;>;"
    const/4 v0, 0x0

    return-object v0
.end method

.method public remove(Lorg/jboss/netty/channel/Channel;)Ljava/lang/Object;
    .locals 3
    .parameter "channel"
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Lorg/jboss/netty/channel/Channel;",
            ")TT;"
        }
    .end annotation

    .prologue
    .line 143
    .local p0, this:Lorg/jboss/netty/channel/ChannelLocal;,"Lorg/jboss/netty/channel/ChannelLocal<TT;>;"
    if-nez p1, :cond_0

    .line 144
    new-instance v1, Ljava/lang/NullPointerException;

    const-string v2, "channel"

    invoke-direct {v1, v2}, Ljava/lang/NullPointerException;-><init>(Ljava/lang/String;)V

    throw v1

    .line 146
    :cond_0
    iget-object v1, p0, Lorg/jboss/netty/channel/ChannelLocal;->map:Ljava/util/concurrent/ConcurrentMap;

    invoke-interface {v1, p1}, Ljava/util/concurrent/ConcurrentMap;->remove(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v0

    .line 147
    .local v0, removed:Ljava/lang/Object;,"TT;"
    if-nez v0, :cond_2

    .line 148
    invoke-virtual {p0, p1}, Lorg/jboss/netty/channel/ChannelLocal;->initialValue(Lorg/jboss/netty/channel/Channel;)Ljava/lang/Object;

    move-result-object v0

    .line 153
    .end local v0           #removed:Ljava/lang/Object;,"TT;"
    :cond_1
    :goto_0
    return-object v0

    .line 150
    .restart local v0       #removed:Ljava/lang/Object;,"TT;"
    :cond_2
    iget-boolean v1, p0, Lorg/jboss/netty/channel/ChannelLocal;->removeOnClose:Z

    if-eqz v1, :cond_1

    .line 151
    invoke-interface {p1}, Lorg/jboss/netty/channel/Channel;->getCloseFuture()Lorg/jboss/netty/channel/ChannelFuture;

    move-result-object v1

    iget-object v2, p0, Lorg/jboss/netty/channel/ChannelLocal;->remover:Lorg/jboss/netty/channel/ChannelFutureListener;

    invoke-interface {v1, v2}, Lorg/jboss/netty/channel/ChannelFuture;->removeListener(Lorg/jboss/netty/channel/ChannelFutureListener;)V

    goto :goto_0
.end method

.method public set(Lorg/jboss/netty/channel/Channel;Ljava/lang/Object;)Ljava/lang/Object;
    .locals 3
    .parameter "channel"
    .parameter
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Lorg/jboss/netty/channel/Channel;",
            "TT;)TT;"
        }
    .end annotation

    .prologue
    .line 97
    .local p0, this:Lorg/jboss/netty/channel/ChannelLocal;,"Lorg/jboss/netty/channel/ChannelLocal<TT;>;"
    .local p2, value:Ljava/lang/Object;,"TT;"
    if-nez p2, :cond_1

    .line 98
    invoke-virtual {p0, p1}, Lorg/jboss/netty/channel/ChannelLocal;->remove(Lorg/jboss/netty/channel/Channel;)Ljava/lang/Object;

    move-result-object v0

    .line 107
    :cond_0
    :goto_0
    return-object v0

    .line 100
    :cond_1
    if-nez p1, :cond_2

    .line 101
    new-instance v1, Ljava/lang/NullPointerException;

    const-string v2, "channel"

    invoke-direct {v1, v2}, Ljava/lang/NullPointerException;-><init>(Ljava/lang/String;)V

    throw v1

    .line 103
    :cond_2
    iget-object v1, p0, Lorg/jboss/netty/channel/ChannelLocal;->map:Ljava/util/concurrent/ConcurrentMap;

    invoke-interface {v1, p1, p2}, Ljava/util/concurrent/ConcurrentMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v0

    .line 104
    .local v0, old:Ljava/lang/Object;,"TT;"
    iget-boolean v1, p0, Lorg/jboss/netty/channel/ChannelLocal;->removeOnClose:Z

    if-eqz v1, :cond_0

    .line 105
    invoke-interface {p1}, Lorg/jboss/netty/channel/Channel;->getCloseFuture()Lorg/jboss/netty/channel/ChannelFuture;

    move-result-object v1

    iget-object v2, p0, Lorg/jboss/netty/channel/ChannelLocal;->remover:Lorg/jboss/netty/channel/ChannelFutureListener;

    invoke-interface {v1, v2}, Lorg/jboss/netty/channel/ChannelFuture;->addListener(Lorg/jboss/netty/channel/ChannelFutureListener;)V

    goto :goto_0
.end method

.method public setIfAbsent(Lorg/jboss/netty/channel/Channel;Ljava/lang/Object;)Ljava/lang/Object;
    .locals 3
    .parameter "channel"
    .parameter
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Lorg/jboss/netty/channel/Channel;",
            "TT;)TT;"
        }
    .end annotation

    .prologue
    .line 118
    .local p0, this:Lorg/jboss/netty/channel/ChannelLocal;,"Lorg/jboss/netty/channel/ChannelLocal<TT;>;"
    .local p2, value:Ljava/lang/Object;,"TT;"
    if-nez p2, :cond_1

    .line 119
    invoke-virtual {p0, p1}, Lorg/jboss/netty/channel/ChannelLocal;->get(Lorg/jboss/netty/channel/Channel;)Ljava/lang/Object;

    move-result-object v0

    .line 129
    :cond_0
    :goto_0
    return-object v0

    .line 121
    :cond_1
    if-nez p1, :cond_2

    .line 122
    new-instance v1, Ljava/lang/NullPointerException;

    const-string v2, "channel"

    invoke-direct {v1, v2}, Ljava/lang/NullPointerException;-><init>(Ljava/lang/String;)V

    throw v1

    .line 124
    :cond_2
    iget-object v1, p0, Lorg/jboss/netty/channel/ChannelLocal;->map:Ljava/util/concurrent/ConcurrentMap;

    invoke-interface {v1, p1, p2}, Ljava/util/concurrent/ConcurrentMap;->putIfAbsent(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v0

    .line 126
    .local v0, mapping:Ljava/lang/Object;,"TT;"
    iget-boolean v1, p0, Lorg/jboss/netty/channel/ChannelLocal;->removeOnClose:Z

    if-eqz v1, :cond_0

    if-nez v0, :cond_0

    .line 127
    invoke-interface {p1}, Lorg/jboss/netty/channel/Channel;->getCloseFuture()Lorg/jboss/netty/channel/ChannelFuture;

    move-result-object v1

    iget-object v2, p0, Lorg/jboss/netty/channel/ChannelLocal;->remover:Lorg/jboss/netty/channel/ChannelFutureListener;

    invoke-interface {v1, v2}, Lorg/jboss/netty/channel/ChannelFuture;->addListener(Lorg/jboss/netty/channel/ChannelFutureListener;)V

    goto :goto_0
.end method
